package com.gitee.feizns.wx.controller;

import com.gitee.feizns.web.domain.result.Ret;
import com.gitee.feizns.wx.domain.ao.JsApiTicketAo;
import com.gitee.feizns.wx.domain.vo.JsApiTicketVo;
import com.gitee.feizns.wx.domain.vo.WxVo;
import com.gitee.feizns.wx.service.WeChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 微信
 * @author feizns
 * @since 2019/7/15
 */
@RestController
public class WeChatController {

    @Autowired
    private WeChatService weChatService;

    /**
     * 获取微信ticket
     * @return
     */
    @PostMapping("/api/js/ticket/{name}")
    public Ret<JsApiTicketVo> ticket(@PathVariable String name, @RequestBody JsApiTicketAo ao) {
        return Ret.ok(weChatService.getJsApiTicket(name, ao));
    }

    /**
     * 获取指定标识的信息
     * @param name
     * @return
     */
    @GetMapping("/{name}")
    public Ret<WxVo> get(@PathVariable String name) {
        return Ret.ok(weChatService.getByName(name));
    }

}
